<?php if (isset($type) && $type == "list"): ?>
    <?php echo image_tag("/uploads/gallery/" . $gallery_item->getId() . "/" . $gallery_item->getPhotoUrl(), array("alt" => $gallery_item->getCaption(), "height" => "32px")) ?>
<?php else: ?>
    <div class="clearfix">
        <?php if (!isset($show_label) || $show_label): ?>
            <?php echo $form["photo"]->renderLabel() ?>
        <?php endif; ?>
        <div class="input">
            <?php if (!$form->isNew()): ?>
                <div class="inline-block">
                    <?php echo image_tag("/uploads/gallery/" . $form->getObject()->getId() . "/" . $form->getObject()->getPhotoUrl(128), array("alt" => $form->getObject()->getCaption(), "height" => "128px")) ?>
                </div>
            <?php endif; ?>
            <div class="inline-block">
                <?php echo $form["photo"] ?>
                <?php if ($form["photo"]->hasError()): ?>
                    <?php include_partial("common/error", array("form" => $form, "field" => "photo", "name_format" => $form->getName())) ?>
                <?php endif; ?>                
            </div>
        </div>
    </div>
    <div>
        <div id="crop-area"></div>    
    </div>
    <script type="text/javascript">
        $(document).ready(function(){
            $("#crop").click(function(){
                $("#crop-area").load("/gallery-item-crop-photo/<?php echo $form->getObject()->getId() ?>").css({padding:"10px 10px 0"});
            });
            $("#crop").colorbox({inline:true, width:"600px", height:"550px", href:"#crop-area", "close":closeHtml, onCleanup:function(){$("#crop-area").empty().css({padding:"0px 0px"});}});
        });
    </script>
<?php endif; ?>